package com.aspose.cells.a.d;

import java.util.ArrayList;

public class zau {
   private zu b;
   private boolean c;
   private zbf d;
   public zfj a;
   private int[] e;
   private ArrayList f;
   private com.aspose.cells.b.a.d.zh g;
   private com.aspose.cells.b.a.d.zh h;
   private com.aspose.cells.b.a.d.zh i;

   public com.aspose.cells.b.a.d.zh a() {
      return this.g;
   }

   public com.aspose.cells.b.a.d.zh b() {
      return this.h;
   }

   public com.aspose.cells.b.a.d.zh c() {
      return this.i;
   }

   public zau(zu var1, boolean var2, zbf var3) {
      this.b = var1;
      this.c = var2;
      this.d = var3;
   }

   public int a(zfx var1, zfx var2, zfj var3) throws Exception {
      this.a(var1);
      this.a(var2, var3);
      this.d();
      return this.f.size() - 1;
   }

   private void a(zfx var1) throws Exception {
      this.b.a().b((long)var1.c);
      int var2;
      int var3;
      if (this.c) {
         var2 = var1.d / 2;
         this.e = new int[var2];

         for(var3 = 0; var3 < var2; ++var3) {
            this.e[var3] = (this.b.e() & '\uffff') * 2;
         }
      } else {
         var2 = var1.d / 4;
         this.e = new int[var2];

         for(var3 = 0; var3 < var2; ++var3) {
            this.e[var3] = this.b.b();
         }
      }

   }

   private void d() throws Exception {
      this.g = new com.aspose.cells.b.a.d.zh();
      zv var1 = new zv(this.g);
      int var2;
      if (this.c) {
         for(var2 = 0; var2 < this.f.size(); ++var2) {
            var1.c((Integer)this.f.get(var2) / 2);
         }
      } else {
         for(var2 = 0; var2 < this.f.size(); ++var2) {
            var1.a((Integer)this.f.get(var2));
         }
      }

      var1.b();
   }

   private void a(zfx var1, zfj var2) throws Exception {
      this.a = new zfj();

      int var5;
      for(int var3 = 0; var3 < var2.a(); ++var3) {
         int var4 = var2.d(var3);
         var5 = (Integer)var2.c(var3);
         if (!this.a.b(var5)) {
            this.a.a(var5, var4);
         }
      }

      this.f = new ArrayList();
      this.h = new com.aspose.cells.b.a.d.zh();
      zv var19 = new zv(this.h);
      this.i = new com.aspose.cells.b.a.d.zh();
      zv var20 = new zv(this.i);
      var5 = 0;

      while(true) {
         while(var5 < this.a.a()) {
            int var6 = (Integer)this.a.c(var5);
            if (var6 >= this.e.length - 1) {
               ++var5;
            } else {
               com.aspose.cells.b.a.a.ze.a(this.f, (Object)((int)var19.a().i() + 3 & -4));
               var19.a(new byte[4], 0, ((int)var19.a().i() + 3 & -4) - (int)var19.a().i());
               this.b.a().b((long)(var1.c + this.e[var6]));
               boolean var7 = false;
               int var8 = var6 + 1;
               int var21 = this.e[var8] - this.e[var6];
               ++var8;
               short var10 = this.b.d();
               if (var21 > 0) {
                  byte[] var11;
                  if (var10 <= 0) {
                     var19.b(var10);
                     var11 = this.b.a(8);
                     var19.a(var11, 0, var11.length);
                     int var9 = var21 - var11.length;

                     int var12;
                     do {
                        var12 = this.b.e() & '\uffff';
                        var19.c(var12);
                        var9 -= 2;
                        int var13 = this.b.e() & '\uffff';
                        Object var15 = var2.e(var13);
                        int var14;
                        if (var15 != null) {
                           var14 = (Integer)var15;
                        } else {
                           int var16 = this.a.d(this.a.a() - 1);
                           var14 = var16 + 1;
                           var2.a(var13, var14);
                           this.a.a(var14, var13);
                        }

                        byte[] var23 = this.b.a(a(var12));
                        var19.c(var14);
                        var9 -= 2;
                        var19.a(var23, 0, var23.length);
                        var9 -= var23.length;
                     } while((var12 & 32) != 0);

                     if ((var12 & 256) != 0) {
                        int var17 = this.b.e() & '\uffff';
                        byte[] var18 = this.b.a(var17);
                        var19.c(var17);
                        var9 -= 2;
                        var19.a(var18, 0, var18.length);
                        var9 -= var18.length;
                     }

                     if (var9 > 0) {
                        this.b.a(var9);
                        var19.a(new byte[20], 0, var9);
                     }
                  } else {
                     this.b.a().b(this.b.a().i() - 2L);
                     var11 = this.b.a(var21);
                     var19.a(var11, 0, var11.length);
                  }
               }

               zbe var22 = this.d.a(var6);
               var22.a(var20);
               ++var5;
            }
         }

         var19.b();
         com.aspose.cells.b.a.a.ze.a(this.f, (Object)((int)var19.a().i() + 3 & -4));
         var19.a(new byte[4], 0, ((int)var19.a().i() + 3 & -4) - (int)var19.a().i());
         var20.b();
         return;
      }
   }

   private static int a(int var0) {
      int var1;
      if ((var0 & 1) != 0) {
         var1 = 4;
      } else {
         var1 = 2;
      }

      if ((var0 & 8) != 0) {
         var1 += 2;
      } else if ((var0 & 64) != 0) {
         var1 += 4;
      } else if ((var0 & 128) != 0) {
         var1 += 8;
      }

      return var1;
   }
}
